<template>
    <div class="login-container">
      <el-card class="login-card">
        <h2 class="login-title">欢迎来到后台管理!</h2>
        <el-form class="login-form" :model="loginForm" ref="loginForm" :rules="rules" label-width="0px">
          <el-form-item prop="username">
            <el-input v-model="loginForm.username" placeholder="Username" prefix-icon="el-icon-user"></el-input>
          </el-form-item>
          <el-form-item prop="password">
            <el-input v-model="loginForm.password" type="password" placeholder="Password" prefix-icon="el-icon-lock"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" class="login-button" @click="login">Login</el-button>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </template>
  
  <script>
    import {useRouter} from "vue-router"
  export default {
    data() {
      return {
        router:useRouter(),
        loginForm: {
          username: '',
          password: ''
        },
        rules: {
          username: [
            { required: true, message: 'Please enter your username', trigger: 'blur' }
          ],
          password: [
            { required: true, message: 'Please enter your password', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      login() {
            this.router.push({
                path:"/Main"
            })
          }
          }
  };
  </script>
  
  <style scoped>
  .login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f3f3f3;
  }
  
  .login-card {
    width: 400px;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  }
  
  .login-title {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
  }
  
  .login-form {
    max-width: 300px;
    margin: 0 auto;
  }
  
  .login-button {
    width: 100%;
  }
  
  .el-input__prefix {
    color: #c0c0c0;
  }
  </style>